package cn.zhuwj.autodiscovery;

import cn.zhuwj.autodiscovery.config.StartConfig;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author zhuwj.cn
 */
public class Test {
    public static void main(String[] args) {
        try {
            AutoDiscoveryStarter.start("192.168.3.3","192.168.3.108",8081,8081,new StartConfig.Callback() {
                @Override
                public void onStart(int total) {
                    System.out.println("开始扫描，total = " + total);
                }

                @Override
                public StartConfig.Next onFound(String ip, Integer port, String serviceName, ThreadPoolExecutor executor) {
                    System.out.println("onFound serviceName = " + serviceName);
                    return StartConfig.Next.CONTINUE_SCAN;
                }

                @Override
                public void onFinished(long ms) {
                    System.out.println("onFinished time = " + (ms / (double) 1000) + "秒");
                }

                @Override
                public void onProgress(String ip, Integer port, int total, int index, int progress, long ms) {
                    System.out.println("当前扫描到 ip = " + ip + " port = " + port + " total = " +total+ " index = " + index +" progress = " + progress + "% 耗时：" + (ms / (double) 1000) + "秒");
                }
            });
        } catch (InterruptedException e) {
            e.printStackTrace();
            Thread.currentThread().interrupt();
        }
    }
}
